package com.xayy.health.core.config.datasource;

import cn.hutool.core.collection.ListUtil;
import cn.kawins.spring.mvc.AbstractInterceptor;
import org.springframework.stereotype.Component;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 重置数据源
 *
 * @author dongxingli
 * createTime 2021/8/24
 * @version V1.0
 */
@Component
public class DatasourceInterceptor extends AbstractInterceptor {

    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        DatasourceHolder.clearSource();
        return true;
    }

    @Override
    public List<String> addPathPatterns() {
        return ListUtil.toList("/**");
    }
}
